<h1>
    <?=$this->title ?>
</h1>
<?
    if (!$this->is_add) // Edit Mode
    {
?>
<div id="right_menu">
    <ul>
<?
        $i = 0;
        foreach($this->menu as $title => $action)
        {
            $i++;
            $container = ($action == 'edit' || $action == 'delete') ? 'inner' : 'container';
?>
        <li
<?
            if (count($this->menu) == $i)
                echo "class=\"last\"";

            if ($this->action == $action)
                echo "class=\"active\"";
?>
            >

            <a href="#"
<?
            if ($action == 'delete')
            {
?>
                onClick="if(confirm('Sure?')) {ajaxFirmwares({id: <?=$this->model_firmware->getID(); ?>,
                                                                action: '<?=$action ?>',
                                                                container: '<?=$container ?>'}); return false;};"
<?
            }
            else
            {
?>
                onClick="ajaxFirmwares({id: <?=$this->model_firmware->getID(); ?>,
                                          action: '<?=$action ?>',
                                          container: '<?=$container ?>',
                                          no_apply: true}); return false;"
<?
            }
?>              ><?=$title ?></a>
	</li>
<?
        };
?>
	</ul>
</div>
<?
    }; //if (!$this->is_add)
?>
<div id="container" <? if ($this->is_add) echo "style=\"margin-top: -50px;\""; ?>>
    <div>
<?
    Principio_Library_Common::printErrorsAndMsg();
?>
        <table class="form_table">
            <tr>
                <td class="title">Caption:</td>
                <td class="input_field">
                    <input type="text" name="caption" id="caption" value="<?=$this->model_firmware->getCaption() ?>" />
                </td>
            </tr>
            <tr>
                <td class="title">Vendor:</td>
                <td class="input_field">
                    <select name="vendor" disabled="disabled">
                        <option value="1" selected>Linksys/Cisco</option>
                    </select>
                </td>
            </tr>
            <tr>
<?
    if ($this->is_add)
    {
?>
                <td class="title">Upload a file:</td>
                <td class="input_field">
                    <input type="file" name="file" id="file" />
                </td>
<?
    }
    else
    {
?>
                <td class="title">File name:</td>
                <td class="input_field"><input type="text" name="file_rd" id="file_rd" disabled="disabled" value="<?=$this->model_firmware->getFileName() ?>"/></td>
                <td class="description">Firmware re-upload is prohibited due to security violation</td>
<?
    };
?>
            </tr>
            <tr>
                <td class="title">Version:</td>
                <td class="input_field">
                    <input type="text" name="version" id="version" value="<?=$this->model_firmware->getVersion(); ?>" />
                </td>
                <td class="description">Will cause an infinite loop if it is wrong!</td>
            </tr>
<?
    if (!$this->is_add)
    {
?>
            <tr>
                <td class="title">Used in types:</td>
                <td class="input_field">
<?
        foreach ($this->used_in_types as $id => $caption)
            echo $caption['caption']." [".$caption['type']."]<br>";
?>
                </td>
            </tr>
<?
    };
?>
        </table>
 	    <table border="0" width="100%" class="buttons">
            <tr>
                <td align="right">
                    <input class="save" type="submit" name="apply" value="<?=($this->is_add ? "Add firmware" : "Apply changes") ?>"
                           onClick="ajaxFirmwares({id: <?=($this->is_add ? "-1" : $this->model_firmware->getID()) ?>, action: '<?=$this->action ?>', container: 'inner'})" />
                    <input class="cancel" type="submit" name="reset" value="Undo All" onClick="<?=($this->is_add ? "addItem({menu: 'firmwares', container: 'inner'})" : "ajaxFirmwares({id: ".$this->model_firmware->getID().", action: 'edit', container: 'inner', no_apply: true})") ?>;"/>
                </td>
            </tr>
        </table>
    </div>
</div>
